import 'package:flutter/material.dart';
import 'package:im_module/common/message_cache_key.dart';
import 'package:im_module/manager/ImChatManager.dart';
import 'package:im_module/message/ShowMessageWidget.dart';
import 'package:im_module/widget/AppBarBackground.dart';

// ignore: must_be_immutable
class ImSystemMessage extends StatefulWidget {
  String id;
  int type = 1;

  ImSystemMessage(this.id);

  @override
  _ImSystemMessageState createState() => _ImSystemMessageState();
}

class _ImSystemMessageState extends State<ImSystemMessage> {
  String _key = "";

  @override
  void initState() {
    super.initState();
    _key = MessageCacheKey.getC2cKey("${widget.id}");
    //设置消息已读
    ImChatManager().markC2CMessageAsRead(widget.type, widget.id);
  }

  @override
  Widget build(BuildContext context) {
    return AppBarBackground(
      child: Scaffold(
        appBar: AppBar(
          title: Text("系统消息"),
          backgroundColor: Colors.transparent,
          centerTitle: true,
        ),
        body: Container(
          color: Color(0xfff0f0f0),
          padding: EdgeInsets.symmetric(vertical: 5),
          child: ShowMessageWidget(widget.type, _key, widget.id, isIm: false),
        ),
      ),
    );
  }
}
